<template>
    <view>
        <cmpt-comm-list
            type="my-fav"
            :search="search || ''"
            :_menus="sortMenus || []"
            :_items="sortItems || []"
            route="favorite/page"
            :isTotalMenu="false"
            topBottom="120"
            placeholder="搜索标题"
            returnUrl="/pages/my/fav/my_fav"
            @list="myCommListListener"
        >
            <!-- List Begin -->
            <view class="text-pic-list-box">
                <view class="item shadow item-simple" @tap="url" :data-url="item.path" v-for="(item, index) in dataList.list" :key="index">
                    <view class="simple">
                        <view class="simple-right">
                            <view class="simple-title content-cut-one">{{ item.relatedName }}</view>
                            <view class="simple-desc">
                                <text class="text-grey text-bold">{{ item.relatedTypeDesc }}</text>
                                <text class="margin-left-s">{{ item.favoriteTime }}</text>
                                <button @tap.stop.prevent="bindDelTap" :data-oid="item.relatedId" :data-type="item.relatedType" class="margin-left btn mid bg-white text-red">
                                    <text class="icon-delete"></text>
                                    删除
                                </button>
                            </view>
                        </view>
                    </view>
                </view>

                <!-- load begin -->

                <!-- parse <template is="listLoadTpl" :data="skin:'load-project',dataList"/> -->
                <block name="listLoadTpl" v-if="false">
                    <view v-if="!dataList || (dataList && dataList.page < dataList.count)" :class="'load text-grey loading ' + 'text-grey'"></view>
                    <view v-if="dataList && dataList.page > 1 && dataList.page == dataList.count" :class="'load text-grey over ' + 'text-grey'"></view>

                    <block v-if="noHintImg">
                        <image style="height: 500rpx" mode="aspectFit" v-if="dataList && dataList.total == 0" :src="noHintImg" />
                    </block>

                    <block v-else>
                        <view v-if="dataList && dataList.total == 0" :class="'load text-grey ' + 'text-grey'">{{ '暂无记录' ? '暂无记录' : '暂无记录哦~' }}</view>
                    </block>

                    <view style="height: 200rpx"></view>
                </block>
                <!-- load end -->
            </view>
            <!-- List END -->
        </cmpt-comm-list>
    </view>
</template>



<script>
const behavior = require('@/utils/comm/behavior/my_fav_bh.js');
const ProjectBiz = require('@/utils/biz/project_biz.js');
const api = require('@/api/api.js');
export default {
    data() {
        return {
            search: '',
            sortMenus: '',
            sortItems: '',

            dataList: {
                list: [],
                page: 0,
                count: 0,
                total: 0
            },

            noHintImg: ''
        };
    },
    mixins: [behavior],
    onReady: function () {
        ProjectBiz.initPage(this);
    },
    methods: {
        // myCommListListener() {
        //     console.log('占位：函数 myCommListListener 未声明');
        // },

        // url() {
        //     console.log('占位：函数 url 未声明');
        // },

        bindDelTap(e) {
            console.log('bindDelTap', e);
            api.removeFav({
                relatedId: e.currentTarget.dataset.oid,
                relatedType: e.currentTarget.dataset.type
            }).then((res) => {
                console.log('res', res);
                //直接刷新页面
                uni.reLaunch({
                    url: '/pages/my/fav/my_fav'
                });
            });
        }
    }
};
</script>
<style>
@import './my_fav.css';
</style>
